package com.ficus.road.maintain.handler.smartdecision.handlers.highway;

import com.ficus.road.maintain.core.model.smartnew.SmartDecisionRequest;
import com.ficus.road.maintain.core.model.smartnew.SmartDecisionResponse;
import com.ficus.road.maintain.handler.smartdecision.handlers.SmartDecisionHandler;
import com.ficus.road.maintain.service.smartnew.StrategySmartDecisionService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author xiawen yang
 * @date 2022/7/20 下午3:34
 */
@Data
@Component
public abstract class AbstractSmartDecisionHighwayHandler implements SmartDecisionHandler {

    @Autowired
    protected StrategySmartDecisionService strategySmartDecisionService;
    private AbstractSmartDecisionHighwayHandler nextHighwayHandler;

    @Override
    public void handle(SmartDecisionRequest request, SmartDecisionResponse response) {
        response = doHandle(request, response);
        if (getNextHighwayHandler() != null) {
            getNextHighwayHandler().handle(request, response);
        }
    }

    public abstract SmartDecisionResponse doHandle(SmartDecisionRequest request, SmartDecisionResponse response);
}
